package NLP;

import com.hankcs.hanlp.HanLP;
import entity.Poem;

import java.util.List;

public class TraditionalChinese2SimplifiedChinese {

    public static String convertToSimplifiedChinese(String traditionalString){
        return HanLP.convertToSimplifiedChinese(traditionalString);
    }

    /**
     * 将poem的paragraph和title字段转成简体中文
     * @param poem
     */
    public static void convertToSimplifiedChinese(Poem poem){
        // 转换内容
       for(int i=0;i<poem.getParagraphs().size();i++){
           poem.getParagraphs().set(i,HanLP.convertToSimplifiedChinese(poem.getParagraphs().get(i)));
       }
       // 转换标题
        poem.setTitle(HanLP.convertToSimplifiedChinese(poem.getTitle()));
    }

    /**
     * 将List<poem>中所有poem的paragraph和title字段转成简体中文
     * @param poemList
     */
    public static void convertToSimplifiedChinese(List<Poem> poemList){
        for (Poem poem:poemList){
            convertToSimplifiedChinese(poem);
        }
    }
}
